﻿using DoNetDrive.Protocol.Door.Door8800;
using DotNetty.Buffers;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace DoNetDrive.Protocol.Fingerprint.SystemParameter
{
    /// <summary>
    /// 设置母卡卡号命令的参数
    /// </summary>
    public class WriteMasterCard_Parameter : AbstractParameter
    {
        /// <summary>
        /// 母卡卡号
        /// </summary>
        public uint MasterCard { get; set; }


        /// <summary>
        /// 构建一个空的设置母卡卡号命令的参数实例,默认禁用所有
        /// </summary>
        public WriteMasterCard_Parameter()
        {
            MasterCard = 0;
        }

        /// <summary>
        /// 创建设置母卡卡号命令的参数
        /// </summary>
        /// <param name="itype">第三方平台类型</param>
        public WriteMasterCard_Parameter(uint card)
        {
            MasterCard = card;
        }

        /// <summary>
        /// 检查参数
        /// </summary>
        /// <returns></returns>
        public override bool checkedParameter()
        {
            return true;
        }

        /// <summary>
        /// 获取数据长度
        /// </summary>
        /// <returns></returns>
        public override int GetDataLen()
        {
            return 4;
        }


        /// <summary>
        /// 释放资源
        /// </summary>
        public override void Dispose()
        {
            return;
        }

        /// <summary>
        /// 编码参数
        /// </summary>
        /// <param name="databuf"></param>
        /// <returns></returns>
        public override IByteBuffer GetBytes(IByteBuffer databuf)
        {
            databuf.WriteInt((int)MasterCard);

            return databuf;
        }

        /// <summary>
        /// 解码参数
        /// </summary>
        /// <param name="databuf"></param>
        public override void SetBytes(IByteBuffer databuf)
        {
            MasterCard = databuf.ReadUnsignedInt();
        }
    }
}
